//
//  TrackitDataEngine.h
//  Trackit
//
//  Created by yaodaobin on 2017/4/8.
//  Copyright © 2017年 yaodaobin. All rights reserved.
//

#import "AFHTTPSessionManager.h"

@interface TrackitDataEngine : AFHTTPSessionManager

+ (TrackitDataEngine *)sharedClient;
+ (TrackitDataEngine *)imageUploadSharedClient;

+ (void)onComplete:(void (^)(NSDictionary *data, NSError *error))block operation:(NSURLSessionDataTask *)operation json:(id)JSON error:(NSError **)outError;
+ (NSMutableDictionary *)rebuildParameter:(NSMutableDictionary *)parameters;

- (NSURLSessionDataTask *)getPath:(NSString *)URLString
                       parameters:(id)parameters
                          success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
                          failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure;

- (NSURLSessionDataTask *)postPath:(NSString *)URLString
                        parameters:(id)parameters
                           success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
                           failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure;

- (NSURLSessionDataTask *)postPath:(NSString *)URLString
                        parameters:(id)parameters
         constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block
                           success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
                           failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure;


#pragma mark - Buisness
+ (void)appLoginAction:(NSMutableDictionary *)parameters onComplete:(void (^)(NSDictionary *data, NSError *error))block;
+ (void)getTaskList:(NSMutableDictionary *)parameters onComplete:(void (^)(NSDictionary *data, NSError *error))block;
+ (void)getTaskDetail:(NSMutableDictionary *)parameters onComplete:(void (^)(NSDictionary *data, NSError *error))block;
+ (void)submitTaskDetail:(NSMutableDictionary *)parameters onComplete:(void (^)(NSDictionary *data, NSError *error))block;
+ (void)completeTaskDetail:(NSMutableDictionary *)parameters onComplete:(void (^)(NSDictionary *data, NSError *error))block;
+ (void)uploadPhoto:(NSData *)imageData withParams:(NSMutableDictionary *)parameters onComplete:(void (^)(NSDictionary *data, NSError *error))block;
#pragma mark -- GET请求 --
+ (void)getWithURLString:(NSString *)URLString
              parameters:(id)parameters
                 success:(void (^)(NSDictionary * dictionary))success
                 failure:(void (^)(NSError * error))failure;

#pragma mark -- POST请求 --
+ (void)postWithURLString:(NSString *)URLString
               parameters:(id)parameters
                  success:(void (^)(id))success
                  failure:(void (^)(NSError *))failure;

#pragma mark -- 上传图片 --
+ (void)uploadWithURLString:(NSString *)URLString
                 parameters:(id)parameters
                 uploadData:(NSData *)uploadData
                 uploadName:(NSString *)uploadName
                    success:(void (^)())success
                    failure:(void (^)(NSError *))failure;

// 上传多张图片
+ (void)uploadMostImageWithURLString:(NSString *)URLString
                          parameters:(id)parameters
                         uploadDatas:(NSArray *)uploadDatas
                          uploadName:(NSString *)uploadName
                             success:(void (^)())success
                             failure:(void (^)(NSError *))failure;
@end
